package com.ideal.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 系统环境工具类
 *
 * @author baiwenhuang
 * @date 2022-11-03 16:45
 **/
@Component
@Slf4j
public class SystemUtils {

    public static boolean isWindows() {
        String osName = getOsName();
        return osName != null && osName.startsWith("Windows");
    }

    public static boolean isMacOs() {
        String osName = getOsName();

        return osName != null && osName.startsWith("Mac");
    }

    public static boolean isLinux() {
        String osName = getOsName();

        return (osName != null && osName.startsWith("Linux")) || (!isWindows() && !isMacOs());
    }


    public static String getOsName() {
        return System.getProperty("os.name");
    }
}
